package com.game.animation;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.RectF;

import com.game.utils.AnimationInterpolatorUtil;

/**
 * 百叶窗
 * @author Administrator
 *
 */
public class AnimationGradualchangeArc extends AnimationGradualchange {
	float startAngle=0;//开始角度
	boolean defDirect=true;//默认顺时钟方向
	
	
	public AnimationGradualchangeArc(AnimationObject object,AnimationGradualchangeCallBack callBack,float startAngle,boolean direct,float time){
		super(object,callBack,time);
		this.startAngle=startAngle;
		this.defDirect=direct;
	}
	
	@Override
	public void step(Canvas canvas,float perc) {
		float x = object.getPostX();
		float y = object.getPostY();
		float w = object.getWidth();
		float h = object.getHeight();
		//求出外接椭圆
		float be=(float) (Math.sqrt(2)/2);
		float width = be*w*2;
		float height = be*h*2;
		float fix_x=(w-width)/2;
		float fix_y=(h-height)/2;
		float sx=x+fix_x;
		float sy=y+fix_y;
		RectF oval = new RectF(sx,sy,sx+width,sy+height);
		if(!defDirect){
			//椭圆外切矩形,开始角度,扫过的角度,是否连接中心点
			canvas.drawArc(oval, startAngle,0-360*perc, true, paint);
		}else{
			canvas.drawArc(oval, startAngle, 360*perc, true, paint);
		}
	}

	public int getSpeedType() {
		return speedType;
	}

	public void setSpeedType(int speedType) {
		this.speedType = speedType;
	}
	
}

